<template>
  <!-- 基本资料 -->
  <view>
    <baseHead title="基本资料" bg="#ffffff" color="#000000"></baseHead>
    <view class="box">
      <view class="content">
        <view class="content_up">
          <view>
            <text>头像</text>
          </view>
          <view class="right_box" @click="success2">
            <u-image
              :src="URL + src"
              width="30"
              height="30"
              shape="circle"
            ></u-image>
            <u-icon name="arrow-right" color="#8188A5"></u-icon>
          </view>
        </view>
      </view>
      <view class="bodybox">
        <view class="body" v-for="(item, key) in List" :key="key">
          <view class="bodycontent" @click="clicks(item)">
            <text>{{ item.text }}</text>
            <view style="display: flex">
              <text>{{ item.value }}</text>
              <u-icon
                name="arrow-right"
                color="#8188A5"
                v-show="
                  true
                    ? item.text == '绑定手机号' || item.text == '绑定邮箱'
                    : ''
                "
              >
                <!--  item.text=='绑定邮箱' : false -->
              </u-icon>
            </view>
          </view>
          <u-line color="#F5F5F5 "></u-line>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import baseHead from "@/pages/component/baseHead.vue";
export default {
  data() {
    return {
      title: "基本资料",
      show: false,
      // 图片访问路径
      URL: this.$config.domain.staticUrl,
      src: "",
      List: [
        {
          text: "用户名称",
          value: "",
          url: "",
        },
        {
          text: "绑定手机号",
          value: "",
          url: "./xiugaishojihao",
        },

        {
          text: "绑定邮箱",
          value: "",
          url: "./xiugaiyouxiang",
        },

        {
          text: "注册时间",
          value: "",
          url: "",
        },
      ],
    };
  },
  components: {
    baseHead,
  },
  onShow() {
    this.ondatetext();
  },
  methods: {
    ondatetext() {
      this.$http.core.myinfo().then((res) => {
        if (res.Code == 0 && res.Success) {
          console.log(res);
          this.List[0].value = res.Result.RealName;
          this.List[1].value = res.Result.PhoneNumber;
          this.List[2].value = res.Result.Email;
          this.List[3].value = res.Result.CreatedTime;
          this.src = res.Result.HeadIcon;
        }
      });
    },
    clicks(item) {
      console.log(item);
      uni.navigateTo({
        url: item.url,
      });
    },
    success2() {
      let that = this;
      uni.chooseImage({
        count: 1,
        sizeType: ["original", "compressed"],
        crop: { width: 60, height: 60 },
        success: (res) => {
          const tempFilePaths = res.tempFilePaths; //图片临时数组
          that.$util.AuploadFile({ src: tempFilePaths[0] }).then((res) => {
            if (res.Success) {
              that.src = res.Result.Path;
              this.upadteBuddhaclose();
            }
          });
        },
      });
    },
    upadteBuddhaclose() {
      let objimg = {
        picurl: this.src,
      };
      this.$http.core.upadteBuddha(objimg).then((res) => {
        console.log(res);
        this.src = "";
        this.ondatetext();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  .content {
    margin-top: 30rpx;
    padding: 30rpx 40rpx;
    background: #ffffff;

    .content_up {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .right_box {
        display: flex;
        align-items: center;
      }
    }
  }

  .bodybox {
    margin-top: 30rpx;

    .body {
      .bodycontent {
        display: flex;
        justify-content: space-between;
        background: #ffffff;
        padding: 30rpx 40rpx;
      }
    }
  }
}
</style>
